<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>글목록</title>
<!-- 테이블 가로줄만 보이게 하기 , A.b=>게시글 링크 색상 A.n=>링크 색상 -->
<style type="text/css">
.tableLine {
	border-top:lightgray 1px solid; border-bottom:lightgray 1px solid; /* 상 하 */
	border-right:lightgray 0px solid;border-left:lightgray 0px solid;}  /* 좌 우 */

A.b:link {text-decoration:none; color:black;} 
A.b:visited {text-decoration:none; color:black;} 
A.b:hover {text-decoration:underline; color:black;} 

A.n:link {text-decoration:none; color:black;} 
A.n:visited {text-decoration:none; color:black;} 
A.n:hover {text-decoration:underline; color:#FF8200;} 
</style> 

<script type="text/javascript">
	// 게시판 리스트 갯수 메뉴 선택
	function viewSelect(){
		if("${requestScope.lvo.pagingBean.isSearch }"==true){ // 검색한 결과 보여주는 중이면
			location.href="board.do?command=searchBoard&board_no=${param.board_no }&kind=${param.kind }&view="+document.getElementById("viewNo").value+"&searchKind=${param.searchKind }&str=${param.str }";
		}else{
			location.href="board.do?command=list&board_no=${param.board_no }&kind=${param.kind }&view="+document.getElementById("viewNo").value;
		}
	}
	// 검색
	function search(){
		var f=document.search_form;
		f.submit();
	}
</script>
</head>

<!-- 게시판 이름 (xx 게시판) -->
<body>
	<table width="760"  height="78" background="img/board/title.jpg">
		<tr>
			<td>
				<font color="green">
					<b>&nbsp;&nbsp;&nbsp;${requestScope.lvo.boardName }
					</b>
				</font>
			</td>
		</tr>
	</table>
	<br>
	<!-- X개씩 보기 메뉴 -->
	<div align="right">
		<select id="viewNo" onchange="viewSelect()">
			<option value=5>5개씩</option>
			<option value=10>10개씩</option>
			<option value=15>15개씩</option>
			<option value=20>20개씩</option>
			<option value=30>30개씩</option>
			<option value=40>40개씩</option>
			<option value=50>50개씩</option>
		</select>
	</div>


<script type="text/javascript">
	// 게시글 보는 갯수
	if("${param.view }"!="") // 게시글 몇개씩 볼건지 param 받으면
		document.getElementById("viewNo").value = "${param.view }";
	else // param 없이 받으면
		document.getElementById("viewNo").value = 15;
</script>

	<br>
<font size="2">
	<table  width="760" cellpadding="5"  
		style="border-top:lightgray 3px solid;
					border-bottom:lightgray 3px solid;
					border-collapse:collapse;
					table-layout: fixed;">
		<tr CLASS="tableLine"  align="center"
			style="background-color:#f6f6f6;">
			<td width="10%"></td>
			<td width="50%">제목</td>
			<td width="15%" align="left">작성자</td>
			<td width="15%">작성일</td>
			<td width="10%">조회</td>
		</tr>		
			<c:forEach var="bvo" items="${requestScope.lvo.list}">		
			<tr CLASS="tableLine" align="center">
			    <td>${bvo.sub_content_no }</td>				
				<td align="left" style="text-overflow : ellipsis; overflow : hidden;">
				<nobr>
					<c:if test="${bvo.restep>0 }">
						<c:forEach begin="1" end="${bvo.relevel }">
						<img src="img/board/blank.jpg">
						</c:forEach>
						<img src="img/board/icon-reply.gif">
					</c:if>
				<a class="b" href="board.do?command=showContent&no=${bvo.content_no }&kind=${param.kind }&view=${param.view }">
				${bvo.title } </a>
				<c:if test="${bvo.newfilename!=null }"><!-- 게시물에 파일첨부 되어 있으면 디스켓 아이콘 -->
					<img src="img/board/icon-file.jpg">
				</c:if>
				<c:if test="${bvo.refly_count>0 }"><!-- 덧글이 달려있으면 덧글 수 출력 -->
					<font size="1" color="#DB631F">[<b>${bvo.refly_count }</b>]</font>
				</c:if>
				<!-- 위 선언부에 하나 추가!  
					 현재 시간을 받아오는 부분 
					 new Data() -> Wed May 09 14:33:36 KST 2012 이런 형식으로 표현된다. -->
				<c:set var="currentDate" value="<%=new Date() %>"/>
				<!-- new Data() 를 2012.5.9 으로 바꿔주는데 
				pattern 속성을 이용해 2012.05.09 형태 등등 표현 가능 -->
				<fmt:formatDate pattern="YYYY.MM.dd" var="curData" value="${currentDate}" type="date"/>	
				 <c:if test="${bvo.writeDate==curData }">
				 	<img src="img/board/new.png">
				</c:if>
				</nobr>
				</td>
				<td align="left">${bvo.nick }</td>
				<td>${bvo.writeDate }</td>
				<td>${bvo.count }</td>
			</tr>
			</c:forEach>
			<tr>
			<td colspan="5" align="right">
				<!-- 글쓰기 버튼 -->
				<a href="board.do?command=writeView&board_no=${param.board_no }&kind=${param.kind }&view=${param.view }"><img alt="글쓰기" src="img/board/write_btn.jpg" border="0"></a>
			</td>
			</tr>
	</table><br>
	</font>
	<center>
	<!-- 페이징 처리 -->	
	<%-- 이전 버튼 --%>
	 <c:if test="${requestScope.lvo.pagingBean.previousPageGroup}">
	 	<c:choose>
		<c:when test="${requestScope.lvo.pagingBean.isSearch }"> <!-- 검색한 결과이면 -->
			<a href=
			"board.do?command=searchBoard&board_no=${param.board_no }&pageNo=${requestScope.lvo.pagingBean.
			startPageOfPageGroup-1}&kind=${param.kind }&view=${param.view }&searchKind=${param.searchKind }&str=${param.str }"><img src="img/board/left_arrow_btn.gif"></a>
		</c:when>
		<c:otherwise>
			<a href=
			"board.do?command=list&board_no=${param.board_no }&pageNo=${requestScope.lvo.pagingBean.
			startPageOfPageGroup-1}&kind=${param.kind }&view=${param.view }"><img src="img/board/left_arrow_btn.gif"></a>
		</c:otherwise>
		</c:choose>
	 </c:if>
	<%-- 페이지 번호 --%>	
	<c:forEach var="i" 
	begin="${requestScope.lvo.pagingBean.startPageOfPageGroup}"
	 end="${requestScope.lvo.pagingBean.endPageOfPageGroup}">
	 <c:choose>
	 <c:when test="${requestScope.lvo.pagingBean.nowPage!=i}">
		 <c:choose>
		 <c:when test="${requestScope.lvo.pagingBean.isSearch }"><!-- 검색한 결과이면 -->
	 		<a class="n" href="board.do?command=searchBoard&board_no=${param.board_no }&pageNo=${i}&kind=${param.kind }&view=${param.view }&searchKind=${param.searchKind }&str=${param.str }">${i}</a>
	 	</c:when>
	 	<c:otherwise>
	 		<a class="n" href="board.do?command=list&board_no=${param.board_no }&pageNo=${i}&kind=${param.kind }&view=${param.view }">${i}</a>
	 	</c:otherwise>
	 	</c:choose>
	 </c:when>
	 <c:otherwise>
	<b><font color="#DB631F" style="text-decoration: underline;">${i}</font></b>
	</c:otherwise>
	</c:choose>
	</c:forEach>
	<%-- 다음 버튼 --%>
	 <c:if test="${requestScope.lvo.pagingBean.nextPageGroup}">
	 <c:choose>
	 <c:when test="${requestScope.lvo.pagingBean.isSearch }"><!-- 검색한 결과이면 -->
	 	<a href=
		 "board.do?command=searchBoard&board_no=${param.board_no }&pageNo=${requestScope.lvo.pagingBean.
		 endPageOfPageGroup+1}&kind=${param.kind }&view=${param.view }&searchKind=${param.searchKind }&str=${param.str }">
		 <img src="img/board/right_arrow_btn.gif">
		 </a>
	 </c:when>
	 <c:otherwise>
		 <a href=
		 "board.do?command=list&board_no=${param.board_no }&pageNo=${requestScope.lvo.pagingBean.
		 endPageOfPageGroup+1}&kind=${param.kind }&view=${param.view }">
		 <img src="img/board/right_arrow_btn.gif">
		 </a>
	 </c:otherwise>
	 </c:choose>
	 </c:if>
	 </center>
	 <br><br>
	</font>
	 <!-- 검색창 -->
	 <center>
	 <form action="board.do" name="search_form" >
		 <input type="hidden" name="command" value="searchBoard">
		 <input type="hidden" name="board_no" value="${param.board_no }">
		 <input type="hidden" name="view" value="${param.view }">
		 <table>
		 <tr>
		 	<td>
				<select id="searchKind" name="searchKind">
					<option value="all">제목+내용</option>
					<option value="title">제목만</option>
					<option value="writer">글작성자</option>
				</select>
			</td>
			<td>
				<input type="text" name="str" maxlength="100" size="20px">
			</td>
			<td>
				<img src="img/board/search_btn.jpg" onclick=search() style='cursor: pointer;'>
			</td>
		</tr>
		</table>
	</form>
	</center>
</body>
</html>













